this.BX=this.BX||{};(function(t,e,i,n,o){"use strict";var a;var l=function(t){babelHelpers.inherits(e,t);function e(){var t;var i=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};babelHelpers.classCallCheck(this,e);t=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(e).call(this));t.html=n.Type.isDomNode(i===null||i===void 0?void 0:i.html)?i.html:null;t.awaitContent=n.Type.isBoolean(i===null||i===void 0?void 0:i.awaitContent)?i===null||i===void 0?void 0:i.awaitContent:null;t.flex=n.Type.isNumber(i===null||i===void 0?void 0:i.flex)?i.flex:null;t.withoutBackground=n.Type.isBoolean(i===null||i===void 0?void 0:i.withoutBackground)?i.withoutBackground:null;t.backgroundColor=n.Type.isString(i===null||i===void 0?void 0:i.backgroundColor)?i.backgroundColor:null;t.backgroundImage=n.Type.isString(i===null||i===void 0?void 0:i.backgroundImage)?i.backgroundImage:null;t.marginBottom=n.Type.isNumber(i===null||i===void 0?void 0:i.marginBottom)?i.marginBottom:null;t.disabled=n.Type.isBoolean(i===null||i===void 0?void 0:i.disabled)?i.disabled:null;t.secondary=n.Type.isBoolean(i===null||i===void 0?void 0:i.secondary)?i.secondary:null;t.overflow=n.Type.isBoolean(i===null||i===void 0?void 0:i.overflow)?i.overflow:null;t.displayBlock=n.Type.isBoolean(i===null||i===void 0?void 0:i.displayBlock)?i.displayBlock:null;t.attrs=n.Type.isPlainObject(i===null||i===void 0?void 0:i.attrs)?i.attrs:null;t.minHeight=n.Type.isString(i===null||i===void 0?void 0:i.minHeight)?i.minHeight:null;t.sizeLoader=n.Type.isNumber(i===null||i===void 0?void 0:i.sizeLoader)?i.sizeLoader:45;t.asyncSecondary=(i===null||i===void 0?void 0:i.asyncSecondary)instanceof Promise?i.asyncSecondary:null;t.layout={container:null};if(t.awaitContent){t["await"]()}return t}babelHelpers.createClass(e,[{key:"getLoader",value:function t(){if(!this.loader){this.loader=new o.Loader({target:this.getContainer(),size:this.sizeLoader})}return this.loader}},{key:"await",value:function t(){this.getContainer().classList.add("--awaiting");this.showLoader()}},{key:"stopAwait",value:function t(){this.getContainer().classList.remove("--awaiting");this.hideLoader()}},{key:"showLoader",value:function t(){void this.getLoader().show()}},{key:"hideLoader",value:function t(){void this.getLoader().hide()}},{key:"getContent",value:function t(){if(this.html){return this.html}return""}},{key:"updateContent",value:function t(e){if(n.Type.isDomNode(e)){n.Dom.clean(this.getContainer());this.getContainer().appendChild(e)}}},{key:"setBackgroundColor",value:function t(e){if(n.Type.isString(e)){this.getContainer().style.backgroundColor=e}}},{key:"getMarginBottom",value:function t(){return this.marginBottom}},{key:"getContainer",value:function t(){var e=this;if(!this.layout.container){this.layout.container=n.Tag.render(a||(a=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="ui-popupcomponentmaker__content--section-item">',"</div>\n\t\t\t"])),this.getContent());if(this.backgroundColor){this.layout.container.style.backgroundColor=this.backgroundColor}if(this.backgroundImage){this.layout.container.style.backgroundImage=this.backgroundImage}if(this.withoutBackground&&!this.backgroundColor){this.layout.container.classList.add("--transparent")}if(this.flex){this.layout.container.style.flex=this.flex}if(this.disabled){this.layout.container.classList.add("--disabled")}if(this.disabled){this.layout.container.classList.add("--disabled")}if(this.secondary){n.Dom.addClass(this.layout.container,"--secondary")}if(this.overflow){this.layout.container.classList.add("--overflow-hidden")}if(this.displayBlock){this.layout.container.classList.add("--block")}if(this.attrs){n.Dom.adjust(this.layout.container,{attrs:this.attrs})}if(this.minHeight){n.Dom.style(this.layout.container,"min-height",this.minHeight)}if(this.asyncSecondary){this.asyncSecondary.then((function(t){if(t===false){n.Dom.removeClass(e.layout.container,"--secondary")}else{n.Dom.addClass(e.layout.container,"--secondary")}}))}}return this.layout.container}}]);return e}(i.EventEmitter);var s,r,d;var u=function(){function t(e){var i=e.id,o=e.target,a=e.content,l=e.width,s=e.cacheable,r=e.contentPadding,d=e.padding,u=e.blurBackground;babelHelpers.classCallCheck(this,t);this.id=n.Type.isString(i)?i:null;this.target=n.Type.isElementNode(o)?o:null;this.content=a||null;this.contentWrapper=null;this.popup=null;this.loader=null;this.items=[];this.width=n.Type.isNumber(l)?l:null;this.cacheable=n.Type.isBoolean(s)?s:true;this.contentPadding=n.Type.isNumber(r)?r:0;this.padding=n.Type.isNumber(d)?d:13;this.blurBlackground=n.Type.isBoolean(u)?u:false}babelHelpers.createClass(t,[{key:"getItems",value:function t(){return this.items}},{key:"getItem",value:function t(e){if(e instanceof l){return e}e=new l(e);if(this.items.indexOf(e)===-1){this.items.push(e)}return e}},{key:"getPopup",value:function t(){var o=this;if(!this.popup){var a=this.width?this.width:350;var l=this.id?this.id+"-popup":null;this.popup=new e.Popup(l,this.target,{className:"ui-popupcomponentmaker",contentBackground:"transparent",contentPadding:this.contentPadding,angle:{offset:a/2-16},width:a,offsetLeft:-(a/2)+(this.target?this.target.offsetWidth/2:0)+40,autoHide:true,closeByEsc:true,padding:this.padding,animation:"fading-slide",content:this.getContentWrapper(),cacheable:this.cacheable});if(this.blurBlackground){n.Dom.addClass(this.popup.getPopupContainer(),"popup-with-radius");this.setBlurBackground();i.EventEmitter.subscribe(i.EventEmitter.GLOBAL_TARGET,"BX.Intranet.Bitrix24:ThemePicker:onThemeApply",(function(){setTimeout((function(){o.setBlurBackground()}),200)}))}this.popup.getContentContainer().style.overflowX=null}return this.popup}},{key:"isShown",value:function t(){return this.getPopup().isShown()}},{key:"getContentWrapper",value:function t(){var e=this;if(!this.contentWrapper){this.contentWrapper=n.Tag.render(s||(s=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="ui-popupcomponentmaker__content"></div>\n\t\t\t'])));if(!this.content){return}this.content.map((function(t){var i;var o=e.getSection();if(t!==null&&t!==void 0&&t.marginBottom){n.Type.isNumber(t.marginBottom)?o.style.marginBottom=t.marginBottom+"px":null}if(t!==null&&t!==void 0&&t.className){n.Dom.addClass(o,t.className)}if(t!==null&&t!==void 0&&t.attrs){n.Dom.adjust(o,{attrs:t.attrs})}if(n.Type.isDomNode(t===null||t===void 0?void 0:t.html)){o.appendChild(e.getItem(t).getContainer());e.contentWrapper.appendChild(o)}if(n.Type.isArray(t===null||t===void 0?void 0:t.html)){var a=n.Tag.render(r||(r=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t\t\t<div class="ui-popupcomponentmaker__content--section-item --flex-column --transparent"></div>\n\t\t\t\t\t'])));t.html.map((function(t){var i;if(t!==null&&t!==void 0&&(i=t.html)!==null&&i!==void 0&&i.then){e.adjustPromise(t,o);n.Type.isNumber(t===null||t===void 0?void 0:t.marginBottom)?o.style.marginBottom=t.marginBottom+"px":null}else{if(n.Type.isArray(t===null||t===void 0?void 0:t.html)){t.html.map((function(t){a.appendChild(e.getItem(t).getContainer())}));o.appendChild(a)}else{o.appendChild(e.getItem(t).getContainer())}}}));e.contentWrapper.appendChild(o)}if(n.Type.isFunction(t===null||t===void 0?void 0:(i=t.html)===null||i===void 0?void 0:i.then)){e.adjustPromise(t,o);e.contentWrapper.appendChild(o)}}))}return this.contentWrapper}},{key:"adjustPromise",value:function t(e,i){e.awaitContent=true;var o=this.getItem(e);if(i){var a;i.appendChild(o.getContainer());e===null||e===void 0?void 0:(a=e.html)===null||a===void 0?void 0:a.then((function(t){if(n.Type.isDomNode(t)){o.stopAwait();o.updateContent(t)}}))}}},{key:"getSection",value:function t(){return n.Tag.render(d||(d=babelHelpers.taggedTemplateLiteral(['\n\t\t\t<div class="ui-popupcomponentmaker__content--section"></div>\n\t\t'])))}},{key:"setBlurBackground",value:function t(){var e=this.getPopup().getPopupContainer();var i=window.getComputedStyle(document.body);var o=i.backgroundImage;var a=i.backgroundColor;if(n.Type.isDomNode(e)){n.Dom.addClass(e,"popup-window-blur")}var l=n.Dom.create("style",{attrs:{type:"text/css",id:"styles-widget-blur"}});var s=".popup-window-content:after { "+"background-image: "+o+";"+"background-color: "+a+"} ";s=document.createTextNode(s);l.appendChild(s);var r=".popup-window-angly:after { "+"background-color: "+a+"} ";r=document.createTextNode(r);l.appendChild(r);var d=document.head.querySelector("#styles-widget-blur");if(d){n.Dom.replace(d,l)}else{document.head.appendChild(l)}}},{key:"show",value:function t(){if(!n.Type.isDomNode(this.target)){return}this.getPopup().show()}},{key:"close",value:function t(){this.getPopup().close()}}]);return t}();t.PopupComponentsMakerItem=l;t.PopupComponentsMaker=u})(this.BX.UI=this.BX.UI||{},BX.Main,BX.Event,BX,BX);
//# sourceMappingURL=popupcomponentsmaker.bundle.map.js